<?php

namespace App\Http\Controllers\Admin;


use App\Models\Permit;
use App\Models\User;
use Illuminate\Http\Request;

class PermitController extends BaseController
{
    /**
     * 权限列表
     * @return string
     */
    public function index()
    {
        $permits = Permit::where('pid', 0)->with(['children' => function($query){
            $query->with(['children' => function ($query){
                $query->with('children');
            }]);
        }])->get();
        return $this->success($permits);
    }

    /**
     * 添加权限
     */
    public function create(Request $request)
    {
        $permit = Permit::create($request->only('pid', 'name', 'alias', 'status', 'level'));
        return $this->success($permit);
    }

    /**
     * 修改权限
     * @param $id
     */
    public function update($id)
    {
        return 'update';
    }

    /**
     * 删除权限
     * @param $id
     */
    public function delete($id)
    {
        return 'delete';
    }

}
